package com.neusoft.neu.fy25g01.n98.controller;

import com.neusoft.neu.fy25g01.n98.entity.CommonResult;
import com.neusoft.neu.fy25g01.n98.entity.Grid;
import com.neusoft.neu.fy25g01.n98.service.GridService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/sys/g")
@CrossOrigin

public class GridController {

    @Autowired
    private GridService gridService;

    @GetMapping("/find/by/id/{gid}")
    public CommonResult<Grid> findById(@PathVariable("gid") int gid) {
        return gridService.findById(gid);
    }


    @GetMapping("/find/by/null")
    public CommonResult<List<Grid>> findAll() {
        return gridService.findAll();
    }

    @PutMapping("/mod")
    public CommonResult<Integer> modGrid(@RequestBody Grid grid) {
        return gridService.modGrid(grid);
    }


    @PostMapping("/add")
    public CommonResult<Integer> addGrid(@RequestBody Grid grid) {
        return gridService.addGrid(grid);
    }

    @DeleteMapping("/del/{gid}")
    public CommonResult<Integer> delGrid(@PathVariable("gid") int gid) {
        return gridService.delGrid(gid);
    }


}
